from common.config import get_config_path
import os
import toml

class TaskMgr:
    def __init__(self):
        self.task_path = get_config_path() + '/tasks'

    def get_task_list(self):
        files = os.listdir(self.task_path)
        tasks = {}
        for filename in files:
            if '.toml' not in filename:
                continue
            task = toml.load(self.task_path + '/' + filename)
            tasks[filename.replace('.toml','')] = task
        return tasks

    def get_result_list(self):
        files = os.listdir(self.task_path)
        names = []
        for name in files:
            names.append(name.replace('.csv',''))
        return names



    def get_task(self, filename):
        task = toml.load(self.task_path + '/' + filename + '.toml')
        return task


if __name__ == '__main__':
    tasks = TaskMgr().get_task_list()
    print(tasks)